package com.tuanzi.loan.web.bean.family;

import static com.tuanzi.loan.business.constants.DictionaryCode.ONLINE_OFFLINE_STATUS;
import static com.tuanzi.loan.business.constants.DictionaryCode.USER_IDENTITY_TAG;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

import org.springframework.stereotype.Component;

import com.google.common.collect.Lists;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.family.UserInfoSearchRequest;
import com.tuanzi.loan.vo.response.family.UserInfoSearchResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.family.UserInfoLazyDataModel;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Ray 2017/09/21
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class UserTagListBean extends JSFListingBean<UserInfoSearchRequest, UserInfoSearchResponse> {

    private static final long serialVersionUID = -2152778554108785342L;

    @PostConstruct
    private void init() {
        initLazyDataModel();
    }

    public void onReset() {
        initLazyDataModel();
    }

    public String onAdd() {
        return redirect("/views/family/tags/user/info.xhtml");
    }

    public String onEdit(String id) {
        return redirect("/views/family/tags/user/info.xhtml?id=" + id);
    }


    private void initLazyDataModel() {
        $ = new UserInfoSearchRequest();
        lazyDataModel = new UserInfoLazyDataModel($);
    }

    @Override
    protected List<String> getDictionaryCodes() {
        return Lists.newArrayList(ONLINE_OFFLINE_STATUS, USER_IDENTITY_TAG);
    }

}
